<title>忘记密码</title>
<div id="login">
	<img src="img/login.png" alt="" />
	<div class="box">

		<div class="innerBox">
			<input type="text" placeholder="邮 箱：" id="femail" >
			<i class="mui-icon mui-icon-email"></i>

		</div>
		<div class="innerBox">
			<input type="text" placeholder="验证码：" id="fcode" style="width: 70%;">
			<i class="mui-icon mui-icon-chatbubble"></i>
			<button type="button" class="mui-btn mui-btn-primary mui-btn-outlined" id="foget_getCodeBtn">获取验证码</button>
			

		</div>
		<div class="innerBox">
			<input type="password" placeholder="新 密 码：" id="fpassword" />
			<i class="mui-icon mui-icon-locked"></i>
		</div>
		<div class="innerBox">
			<input type="password" placeholder="确认密码：" id="fpassword2" />
			<i class="mui-icon mui-icon-locked"></i>
		</div>

		<button id="onChangePass">修改</button>

	</div>
</div>
<script type="text/javascript">
	$("#login").height($(window).height())
	$(window).resize(function() {
		$("#login").height($(window).height())
	})

	$(function() {
		var fBol = true;
		$('#foget_getCodeBtn').on("tap", function() {

			if($('#femail').val() == "") {
				mui.alert("邮箱不能为空")

			} else if(!emailGe($('#femail').val()) == false) {
				return false;
			} else {
				fBol = setTime($('#femail').val(), $('#foget_getCodeBtn'), fBol, "/wechat_mt5/user/forget/pwd/send/mail", "get")

			}

		})
		$('#onChangePass').on("tap", function() {

			if($('#fpassword').val() == "") {
				mui.alert("请输入新密码!");
			} else if($('#fpassword').val() != $('#fpassword2').val()) {
				mui.alert("确认密码错误!");
			} else if($('#femail').val() == "") {
				mui.alert("邮箱不能为空!");
			} else if($('#fcode').val() == "") {
				mui.alert("验证码不能为空!");
			} else if(emailGe($('#femail').val()) == false) {
				return false;
			} else if($('#fpassword').val().length < 6 || $('#fpassword').val().length > 16) {
				mui.alert("密码长度6到16位之间！")
			} else {

				$.ajax({
					type: "post",
					url: "/wechat_mt5/user/forget/pwd",
					data: {

						newPassword: $('#fpassword').val(),
						mail: $('#femail').val(),
						mailValidationCode: $('#fcode').val(),

					},
					success: function(data) {

						if(data.code == 0) {
							if(data.data) {

								mui.alert("恭喜您修改成功！");
								window.location.href = "#/login"

							} else {
								mui.alert("修改失败！");
							}
						} else if(data.code == 10010007) {
							mui.alert("修改失败，验证码错误！");
						}

					},
					error: function(data) {

					}
				});
			}

		})
	})
</script>